package com.rui.patterns.flyweight;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : Client
 * @createTime : [2022/2/23 16:16]
 * @description : [描述该类的功能]
 */

public class Client {
    public static void main(String[] args) {
        //获取I图形对象
        AbstractBox box1 = BoxFactory.getInstance().getShape("I");
        box1.display("灰色");

        //获取O图形对象
        AbstractBox box2 = BoxFactory.getInstance().getShape("O");
        box2.display("灰色");

        //获取L图形对象
        AbstractBox box3 = BoxFactory.getInstance().getShape("L");
        box3.display("绿色");

        //获取L图形对象
        AbstractBox box4 = BoxFactory.getInstance().getShape("L");
        box4.display("红色");

        //验证两次获取到的L图形对象是否是同一个对象
        System.out.println(box3 == box4);
    }
}
